export default {
  mounted () {
    setTimeout(() => {
      let config = JSON.parse(localStorage.getItem('config'))
      this.educationList = config.education_setting
    }, 1000)

    this.uuid = this.$route.query.uuid
  },
  methods: {
    close () {
      this.$emit('close', null)
    },

    finished () {
      this.$refs.form.validate(valid => {
        if (valid) {
          this.form.uuid = this.uuid
          this.$axios.post(this.editUrl, this.form)
            .then(response => {
              if (response.data.code === 1) {
                console.log('保存成功')
                this.$emit('finished', response.data.data)
              } else {
                console.log(response.data.msg)
              }
            })
            .catch(() => { console.log('exception') })
        }
      })
      return false
    },

    // 删除
    del () {
      let data = {
        uuid: this.uuid,
        id: this.row.id
      }
      let that = this
      this.$dialog({
        title: '提示',
        content: '确认删除么？',
        onOkBtn (event) {
          this.$axios.post(that.delUrl, data)
            .then(response => {
              if (response.data.code === 1) {
                that.$emit('finished', null)
              }
            })
            .catch(() => { })
          this.close()
        }
      })
    }
  },
  watch: {
    isVisible (val) {
      this.showDialog = val
    },
    row (val) {
      this.form = val
    }
  }
}
